#ifndef LCD_1602_4WIRE_H_
#define LCD_1602_4WIRE_H_

#define DATA 	1
#define CMD  	0
#define READ	1
#define WRITE	0

#include<alt_types.h>
#include<unistd.h>

#include <stdio.h>
#include "system.h"

#include "altera_avalon_uart.h"
#include "sys/alt_dev.h"
#include <stdlib.h> // malloc, free
#include <string.h>
#include <stddef.h>
#include <unistd.h>  // usleep (unix standard?)
#include <fcntl.h>
#include "altera_avalon_pio_regs.h"

//check if the LCD 1602 is in busy
void LcdCheckBusy();
//set the beginning coordinate of the word
void LocateXY(alt_u8 x,alt_u8 y);
//LCD writing function,the argument RS decide a data or a command to be written
void LcdWrite(alt_u8 data,alt_u8 RS);
//LCD reading function,the argument RS decide a data or a command to be read
alt_u8 LcdRead(alt_u8 RS);
//write a command to LCD 1602
void LcdWriteCmd(alt_u8 command);
//write a byte of data to LCD 1602
void LcdWriteData(alt_u8 data);
//read a command from LCD 1602
alt_u8 LcdReadCmd();
//read a data from LCD 1602
alt_u8 LcdReadData();

/*use the following function to initial the LCD 1602 and print words */

//initial the LCD 1602
void InitLcd();
//print a char
void PutChar(char value,alt_u8 x,alt_u8 y);
//print a string
alt_u8 PutStr(char *value,alt_u8 x,alt_u8 y);
//clear screen
void LcdClearScreen();
#endif /* LCD_1602_4WIRE_SOLUTION_H_ */
